package com.njlime.cms.service.sys;

import com.njlime.cms.entities.TColumn;
import com.njlime.cms.repository.sys.ColumnDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ClassName:
 * @Description:
 *  
 * @version        V1.0  
 * @Date           2016-4-3 下午11:27:09 
 */
@Service
@Transactional(readOnly = true)
public class ColumnService {

    @Resource
    private ColumnDao columnDao;

	@Transactional(readOnly = false)
	public   void save(TColumn entity){
        columnDao.save(  entity);
	}

    /**
     * 修改
     * @param name
     * @param id
     */
    @Transactional(readOnly = false)
    public void updateColumn(String name, int id,int unitId,int channelShort){
        columnDao.update(name, id,unitId,channelShort);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    public TColumn findOne(String id){
        return columnDao.findOne(Integer.valueOf(id));
    }


    /**
     * 根据名称查询
     * @param name1
     * @return
     */
    public TColumn getColumnByName(String name1,int unitId,int channelShort) {

        return columnDao.getColumnByName(name1,unitId,channelShort);
    }

    /**
     * 列表
     * @return
     */
    public List<Map<String, Object>> getColumnList(int channelShort,int unitId) {
        return columnDao.getColumnList( channelShort, unitId);
    }

    /**
     * 删除
     * @param id
     */
    @Transactional(readOnly = false)
    public void delete(String id,int unidId) {
        columnDao.delete(id,unidId);
    }

    public Object getAllColumnList() {
        return columnDao.getAllColumnList();
    }

    /**
     * 根据栏目id查询栏目
     * @param columns 栏目id，多个栏目逗号隔开
     * @return
     */
    public List listByChannelId(String columns) {
            return columnDao.listByChannelId(columns);
    }

    public List<Map<String, Object>> getColumnListByChannelId(int channelId,int unitId) {
        return  columnDao.getColumnListByChannelId(channelId,unitId);
    }

    /**
     * 根据频道id查询已经启动的栏目
     * @param channelShort
     * @param unitId
     * @return
     */
    public List<Map<String, Object>> getChannelColumnListByChannelId(int channelShort,int unitId) {
        return  columnDao.getChannelColumnListByChannelId(channelShort,unitId);
    }
}
